State machine basic functionality.
More...
Go to the source code of this file.
Defines |
|
#define | TRUE (1u) |
|
#define | CLEAR (0u) |
|
#define | BITS_IN_NIBBLE (4u) |
|
#define | BITS_IN_BYTE (8u) |
|
#define | BYTES_IN_16 (2u) |
|
#define | BYTES_IN_32 (4u) |
|
#define | BIT_DEFINITION |
|
#define | BIT0 (1u << 0u) |
|
#define | BIT1 (1u << 1u) |
|
#define | BIT2 (1u << 2u) |
|
#define | BIT3 (1u << 3u) |
|
#define | BIT4 (1u << 4u) |
|
#define | BIT5 (1u << 5u) |
|
#define | BIT6 (1u << 6u) |
|
#define | BIT7 (1u << 7u) |
|
#define | BIT8 (1u << 8u) |
|
#define | BIT9 (1u << 9u) |
|
#define | BIT10 (1u << 10) |
|
#define | BIT11 (1u << 11) |
|
#define | BIT12 (1u << 12) |
|
#define | BIT13 (1u << 13) |
|
#define | BIT14 (1u << 14) |
|
#define | BIT15 (1u << 15) |
|
#define | BIT16 (1u << 16) |
|
#define | BIT17 (1u << 17) |
|
#define | BIT18 (1u << 18) |
|
#define | BIT19 (1u << 19) |
|
#define | BIT20 (1u << 20) |
|
#define | BIT21 (1u << 21) |
|
#define | BIT22 (1u << 22) |
|
#define | BIT23 (1u << 23) |
|
#define | BIT24 (1u << 24) |
|
#define | BIT25 (1u << 25) |
|
#define | BIT26 (1u << 26) |
|
#define | BIT27 (1u << 27) |
|
#define | BIT28 (1u << 28) |
|
#define | BIT29 (1u << 29) |
|
#define | BIT30 (1u << 30) |
|
#define | BIT31 (1u << 31) |
|
#define | SM_STATE_IS_EXECUTING BIT30 |
|
#define | SM_INVALID_SOURCE_STATE BIT31 |
|
#define | N_ELEMENTS(X) (sizeof(X)/sizeof(*(X))) |
|
#define | LOCK_STATE_EXECUTION() gu32SMStateStatus |= SM_STATE_IS_EXECUTING |
|
#define | UNLOCK_STATE_EXECUTION() gu32SMStateStatus &= ~SM_STATE_IS_EXECUTING |
Enumerations |
| enum | SM_STATE_VARIABLE_INDEX { SM_PREVIOUS_STATE = 0u,
SM_NEXT_STATE
} |
| enum | SM_STATE_INDEX {
SM_STATE_APP_INIT = 0u,
SM_STATE_ERROR,
SM_STATE_ACQUISITION,
SM_STATE_DECISION,
SM_STATE_DEPLOYMENT,
SM_STATE_SYSTEM_TEST,
SM_STATE_GUI
} |
Functions |
| uint32_t | u32fnSMLaunch (void) |
| | Launches the State Machine and loops forever from one state to the next.
|
| void | vfnSMWriteNextState (uint16_t u16NextState) |
| | Writes the next state to gu16SMCurrentState[1]; Keeps the past state as the current one to gu16SMCurrentState[0].
|
| uint32_t | u32fnSMValidateCurrentState (uint16_t *pu16ValidStateList, uint16_t u16Size) |
| | Function used in each state to validate if the reason we got here is valid.
|
| uint32_t | u32fnSMAppInit (void) |
| | First state in all state machines; prepares the State machine for operation. It also performs hardware initializations as required by the application.
|
| uint32_t | u32fnStateAcquisition (void) |
| | Acquisition state.
|
| uint32_t | u32fnStateDecision (void) |
| | Decision state.
|
| uint32_t | u32fnStateDeployment (void) |
| | Deployment state.
|
| uint32_t | u32fnStateSystemTest (void) |
| | SystemTest state.
|
| uint32_t | u32fnStateError (void) |
| | Error state.
|
| uint32_t | u32fnStateGUI (void) |
| | Demo mode GUI state takes over diagnostics state.
|
Variables |
| uint16_t | gu16SMCurrentState [2u] |
| uint32_t | gu32SMStateStatus |
| uint32_t(*const | u32pfnState [])(void) |
Detailed Description
State machine basic functionality.
Copyright (C) 2011 Freescale Semiconductor Freescale Confidential Proprietary
- Author:
- Freescale Semiconductor
-
SASD Automotive
-
r11515
- Version:
- Date:
- Warning:
- (If needed)
History:
Function Documentation
| uint32_t u32fnSMAppInit |
( |
void |
| ) |
|
First state in all state machines; prepares the State machine for operation. It also performs hardware initializations as required by the application.
- Parameters:
-
- Returns:
- u32Status: Should always be clear.
- Note:
- This should always be the first state.
| uint32_t u32fnSMLaunch |
( |
void |
| ) |
|
Launches the State Machine and loops forever from one state to the next.
- Parameters:
-
- Returns:
- u32Status: Always zero. This function should never exit.
| uint32_t u32fnSMValidateCurrentState |
( |
uint16_t * |
pu16ValidStateList, |
|
|
uint16_t |
u16Size |
|
) |
| |
Function used in each state to validate if the reason we got here is valid.
- Parameters:
-
| pu16ValidStateList,: | a pointer to an array with a list of valid source states. |
| u16Size,: | Size of the table in pu16ValidStateList. |
- Returns:
- u32Status: Clear if it is a valid source; SM_STATE_IS_EXECUTING if this state was entered while another one was already executing; SM_INVALID_SOURCE_STATE if the source state is not in the pu16ValidStateList.
| uint32_t u32fnStateAcquisition |
( |
void |
| ) |
|
Acquisition state.
- Parameters:
-
- Returns:
- u32Status: Clear if it is a valid source; SM_STATE_IS_EXECUTING if this state was entered while another one was already executing; SM_INVALID_SOURCE_STATE if the source state is not in the pu16ValidStateList; other error codes are also possible.
| uint32_t u32fnStateDecision |
( |
void |
| ) |
|
Decision state.
- Parameters:
-
- Returns:
- u32Status: Clear if it is a valid source; SM_STATE_IS_EXECUTING if this state was entered while another one was already executing; SM_INVALID_SOURCE_STATE if the source state is not in the pu16ValidStateList; other error codes are also possible.
| uint32_t u32fnStateDeployment |
( |
void |
| ) |
|
Deployment state.
- Parameters:
-
- Returns:
- u32Status: Clear if it is a valid source; SM_STATE_IS_EXECUTING if this state was entered while another one was already executing; SM_INVALID_SOURCE_STATE if the source state is not in the pu16ValidStateList; other error codes are also possible.
| uint32_t u32fnStateError |
( |
void |
| ) |
|
Error state.
- Parameters:
-
- Returns:
- u32Status: Clear if it is a valid source; SM_STATE_IS_EXECUTING if this state was entered while another one was already executing; SM_INVALID_SOURCE_STATE if the source state is not in the pu16ValidStateList; other error codes are also possible.
| uint32_t u32fnStateGUI |
( |
void |
| ) |
|
Demo mode GUI state takes over diagnostics state.
- Parameters:
-
- Returns:
- u32Status: Clear if it is a valid source; SM_STATE_IS_EXECUTING if this state was entered while another one was already executing; SM_INVALID_SOURCE_STATE if the source state is not in the pu16ValidStateList; other error codes are also possible.
| uint32_t u32fnStateSystemTest |
( |
void |
| ) |
|
SystemTest state.
- Parameters:
-
- Returns:
- u32Status: Clear if it is a valid source; SM_STATE_IS_EXECUTING if this state was entered while another one was already executing; SM_INVALID_SOURCE_STATE if the source state is not in the pu16ValidStateList; other error codes are also possible.
| void vfnSMWriteNextState |
( |
uint16_t |
u16NextState | ) |
|
Writes the next state to gu16SMCurrentState[1]; Keeps the past state as the current one to gu16SMCurrentState[0].
- Parameters:
-
| u16NextState,: | the index to the next state. |
- Returns:
- void
Variable Documentation
Array that holds the current state, and the previous one as well. Previous state is held in position 0, current state is held in position 1.
Global state for the state machine
The element below is a constant array of pointers to functions where